#include "esp_log.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_idf_version.h"

#include "button_task.h"
#include "spi_config.h"
#include "ui_task.h"

const char* main_log_module = "main_Module";

void app_main(void)
{
    esp_err_t ret;

    const char* idf_version = esp_get_idf_version();
    esp_log_level_set(main_log_module, ESP_LOG_INFO);
    ESP_LOGI(main_log_module,"idf Version:%s", idf_version);

    UBaseType_t priority = uxTaskPriorityGet(NULL);
    ESP_LOGI(main_log_module,"app_main priority:%d", priority);
    
    /* 初始化按键相关中断与任务*/
    ret = button_init();
    ESP_ERROR_CHECK(ret);

    /* 初始化SPI驱动*/
    ret = ESP_SPI_driver_init();
    ESP_ERROR_CHECK(ret);

    /* 初始化屏幕UI界面与相关任务*/
    ret = ui_init();
    ESP_ERROR_CHECK(ret);

    // 初始化完成后删除此任务
    vTaskDelete(NULL);
}
